home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / misc / GMSV03B.lha / GamesMaster / Source / Asm / RasterEffects / ColourLists.s < prev    next >
Encoding:
Text File  |  1996-09-08  |  4.9 KB  |  163 lines

  1. ;Colour List Example
  2. ;-------------------
  3. ;Colourlists are those nice colour gradients used in demos and games,
  4. ;usually  sitting in the background of your screen.  Colourlists are mostly
  5. ;good for getting more colours on screen than what there really is.
  6. ;Although  the games.library allows you to do other screen effects based on
  7. ;raster lines, we'll just stick to changing colours in this demo.
  8. ;
  9. ;You can move the green colour bar by moving the joystick up and down.
  10. ;You will notice that if you move the green bar into the upper red bar,
  11. ;your bar will disappear.  This is because:
  12. ;
  13. ;    WAITLINE  95        ;Wait for line 95
  14. ;    WAITLINE 100        ;Wait for line 100
  15. ;    WAITLINE  90        ;Wait for line 90 <--Error! 
  16. ;
  17. ;Is not allowed.  The monitor beam travels down the screen, and so the
  18. ;Update_RasterList routine will expect all lines to be in sequential order.
  19. ;Moving two colourbars into each other breaks this rule, causing the wait
  20. ;command to be ignored.  If you want to get around this, you will have to
  21. ;have just one large colourlist and sort your colours before each call to
  22. ;Update_RasterList.
  23. ;
  24. ;Similarly if you move the colour bar too far down the screen the hardware
  25. ;won't like it because lines > 311 don't exist.  It's up to you to be
  26. ;responsible enough to stop this from happening!
  27. ;
  28. ;Press FIRE to exit the demo.
  29.  
  30.     opt    o+,d+
  31.  
  32.     INCLUDE    "exec/exec_lib.i"
  33.     INCLUDE    "games/games_lib.i"
  34.     INCLUDE    "games/games.i
  35.  
  36. CALL    MACRO
  37.     jsr    _LVO\1(a6)
  38.     ENDM
  39.  
  40. ;===========================================================================;
  41. ;                             INITIALISE DEMO
  42. ;===========================================================================;
  43.  
  44.     SECTION    "ColourList",CODE
  45.  
  46. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  47.     move.l    ($4).w,a6
  48.     lea    GMS_Name(pc),a1
  49.     moveq    #$00,d0
  50.     CALL    OpenLibrary
  51.     move.l    d0,GMS_Base
  52.     beq.s    Quit
  53.  
  54.     move.l    GMS_Base(pc),a6
  55.     CALL    SetUserPri
  56.  
  57.     move.l    GMS_Base(pc),a6          ;Tell GMS that we want to add a
  58.     lea    ScreenStruct(pc),a0      ;screen for use.
  59.     CALL    Add_Screen
  60.     tst.l    d0
  61.     bne.s    Error
  62.  
  63.     lea    ScreenStruct(pc),a0      ;Now show the screen/pic.
  64.     CALL    Show_Screen
  65.  
  66.     moveq    #JPORT1,d0               ;Port 1
  67.     CALL    Read_Mouse               ;Initialise the port.
  68.  
  69. ;===========================================================================;
  70. ;                                MAIN LOOP
  71. ;===========================================================================;
  72.  
  73. Loop:    moveq    #JPORT1,d0               ;Port 1
  74.     CALL    Read_Mouse
  75.     btst    #MB_LMB,d0
  76.     bne.s    ReturnToDOS
  77.     ext.w    d0
  78.  
  79.     lea    Bar2(pc),a1
  80.     add.w    d0,2(a1)
  81.  
  82. .chkhi    cmp.w    #226,2(a1)
  83.     blt.s    .chklo
  84.     move.w    #226,2(a1)
  85.  
  86. .chklo    tst.w    2(a1)
  87.     bgt.s    .update
  88.     clr.w    2(a1)
  89.  
  90. .update    CALL    Update_RasterLines       ;>> = Update our rasterlist.
  91.     CALL    Wait_OSVBL
  92.     bra.s    Loop
  93.  
  94. ;===========================================================================;
  95. ;                              RETURN TO DOS
  96. ;===========================================================================;
  97.  
  98. ReturnToDOS:
  99.     move.l    GMS_Base(pc),a6
  100.     lea    ScreenStruct(pc),a0
  101.     CALL    Delete_Screen            ;Give back screen memory etc.
  102. Error:    move.l    GMS_Base(pc),a1
  103.     move.l    ($4).w,a6
  104.     CALL    CloseLibrary
  105. Quit:    MOVEM.L    (SP)+,A0-A6/D1-D7
  106.     moveq    #$00,d0
  107.     rts
  108.  
  109. ;===========================================================================;
  110. ;                                  DATA
  111. ;===========================================================================;
  112.  
  113. GMS_Name:
  114.     dc.b    "games.library",0
  115.     even
  116. GMS_Base:
  117.     dc.l    0
  118.  
  119. AMT_PLANES =    5
  120.  
  121. ScreenStruct:
  122.     dc.l    "GSV1",0          ;Structure version.
  123.     dc.l    0,0,0             ;Screen_Mem1/2/3
  124.     dc.l    0                 ;Screen link.
  125.     dc.l    0                 ;Address of screen palette.
  126.     dc.l    RasterList        ;Address of rasterlist.
  127.     dc.l    0                 ;Amt of colours in palette.
  128.     dc.w    320,256,320,256   ;Screen & Pic Height/Width.
  129.     dc.w    AMT_PLANES        ;Amt_Planes
  130.     dc.w    0,0               ;X/Y screen offset.
  131.     dc.w    0,0               ;X/Y picture offset.
  132.     dc.l    BLKBDR            ;Special attributes.
  133.     dc.w    LORES             ;Screen mode.
  134.     dc.b    INTERLEAVED       ;Screen type
  135.     dc.b    0                 ;Reserved
  136.     even
  137.  
  138. ;===========================================================================;
  139.  
  140. RasterList:
  141. Bar1:    COL12LIST 000,3,00,ColourBar1    ;Line, Skip, Colnum, ColourList.
  142. Bar2:    COL12LIST 160,1,00,ColourBar2    ;Line, Skip, Colnum, ColourList.
  143.     COL12LIST 230,1,00,ColourBar3    ;Line, Skip, Colnum, ColourList.
  144.     RASTEND
  145.  
  146. ColourBar1:
  147.     dc.w    $100,$200,$300,$400,$500,$600,$700,$800,$900,$a00
  148.     dc.w    $b00,$c00,$d00,$e00,$e00,$e00,$d00,$c00,$b00,$a00
  149.     dc.w    $900,$800,$700,$600,$500,$400,$300,$200,$100,$000
  150.     dc.w    -1
  151.  
  152. ColourBar2:
  153.     dc.w    $010,$020,$030,$040,$050,$060,$070,$080,$090,$0a0
  154.     dc.w    $0b0,$0c0,$0d0,$0e0,$0f0,$0e0,$0d0,$0c0,$0b0,$0a0
  155.     dc.w    $090,$080,$070,$060,$050,$040,$030,$020,$010,$000
  156.     dc.w    -1
  157.  
  158. ColourBar3:
  159.     dc.w    $001,$002,$003,$004,$005,$006,$007,$008,$009,$00a
  160.     dc.w    $00b,$00c,$00d,$00e,$00f,$00e,$00d,$00c,$00b,$00a
  161.     dc.w    $009,$008,$007,$006,$005,$004,$003,$002,$001,$000
  162.     dc.w    -1
  163.